IBM Support

Process Memory Accounting Using svmon

Question & Answer


Question

This document describes how to use the svmon command to calculate the amount of memory used exclusively by a single process.

Answer


The amount of memory used by a process, as reported by commands such as ps, is usually higher than expected. This is because some of the memory included in the report is shared with other processes. The svmon -P PID command can be used to calculate how much memory is being used exclusively by a single process.

Example svmon -P PID Output

The svmon -P PID command reports detailed memory usage for a single process. The output is divided into three sections; two summary section at the top, and a detail section at the bottom. Below is example output for a process named extproc with process ID 1639538.

# svmon -P 1639538
    Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd   Summary Section A
1639538 extproc          51174     8304        0    49402      Y     N

    PageSize                Inuse        Pin       Pgsp    Virtual       Summary Section B
    s    4 KB                8774          0          0       7002
    m   64 KB                2650        519          0       2650

Vsid     Esid     Type Description         PSize Inuse Pin Pgsp Virtual  Detail Section
1148029  90000000 work shared library text m     1287  ... ...  ...
...

In Summary Section A the Inuse column is the total amount of memory used by the process, reported above as 51,174 4KB blocks. This value includes system memory that is shared by other processes on the system, and is usually much higher than the amount of memory used exclusively by the process.

Summary Section B shows a breakdown of memory usage by page size. As we see below, the values in each line of the Inuse column add up to the Inuse value in Summary Section A.

    PageSize                Inuse        Pin       Pgsp    Virtual
    s    4 KB                8774          0          0       7002
    m   64 KB                2650        519          0       2650
                                |
                                          8774 4KB
                             2650 64KB = 42400 4KB
                                         -----
                                         51174 4KB    <<<<

The Detail Section lists segments that are both private to the process, and shared among one or more processes. A segment is a maximum of 256MB in size. The shared library text segment, for example, is shared by all processes on the system, so the memory used by this segment should not be included when calculating memory used only by a single process.

In the Detail Section of this svmon report, we see below that a shared library text segment is using 1,287 64KB pages, which equals 20,592 4KB pages, which equals about 84MB. The page size is shown as m, meaning a medium sized page of 64KB. The 20,592 amount is included in the 51,174 total, so we see that already, almost half of the total memory is shared and not exclusive to this single process.

1148029  90000000 work shared library text m     1287  ... ...  ...

Shared segments also include mmap segments, which are shared by multiple processes within the same application, and file cache segments. These types of segments should not be included when calculating the amount of memory used by a single process.

Notes About svmon -P Output

  • All summary lines lists memory in 4KB blocks.
  • Small sized pages are 4KB and represented by s.
  • Medium sized pages are 64KB and represented by m.
  • Mixed page size segments contain both 4KB and 64KB pages and are represented with sm. The total memory used by these segments however, is displayed as 4KB blocks.
  • Some segments are used for file cache. The Esid will be listed as "-" and in the description field, the actual file inode is listed.

A Better Method to Report Exclusive Memory

A better method to see memory that is used exclusively by a single process is the following svmon command:

svmon -P PID -O segment=category -O filterprop=data

This command divides the segments into the following categories:
  • System
    Shared by all processes
  • Exclusive
    Exclusive to only a single process

The memory used by the exclusive segments can be used to calculate approximately how much memory is used exclusively by this single process. Here is an example.

# svmon -P 1639538 -O segment=category -O filterprop=data
Unit: page
------------------------------------------------------------------------

    Pid Command          Inuse      Pin     Pgsp  Virtual
1639538 extproc          50959     8304        0    49402

........................................................................

SYSTEM segments                      Inuse      Pin     Pgsp  Virtual
                                    11758     8256        0    11758

   Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp
  10002         0 work kernel segment               m    584   516    0
  28005  9ffffffd work shared library              sm   2376     0    0
  6000c  9ffffffe work shared library              sm     22     0    0
104f90d  8fffffff work private load data            s     16     0    0

........................................................................

EXCLUSIVE segments                   Inuse      Pin     Pgsp  Virtual
                                     3351       48        0     3351

   Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp
16c79dc        11 work text data BSS heap          sm   1842     0    0
17078e4  8001000a work private load data           sm    789     0    0
10ef419  80020014 work USLA heap                   sm    347     0    0
124794c  9001000a work shared library data         sm    152     0    0
16f78da  ffffffff work application stack           sm    141     0    0
13dd67d f00000002 work process private              m      5     3    0
1087914  fffffffd work application stack           sm      0     0    0
128f955  fffffff7 work application stack           sm      0     0    0
1195735  fffffff2 work application stack           sm      0     0    0
12ce65d  fffffff4 work application stack           sm      0     0    0
13ff97b  fffffffb work application stack           sm      0     0    0
1227940  fffffffc work application stack           sm      0     0    0
139e272  fffffff1 work application stack           sm      0     0    0
1607ec5  fffffff3 work application stack           sm      0     0    0
1629dc1  fffffffe work application stack           sm      0     0    0
14e7798  fffffff5 work application stack           sm      0     0    0
162f2c1  fffffffa work application stack           sm      0     0    0
10fbe18  fffffff0 work application stack           sm      0     0    0
13a7870  fffffff9 work application stack           sm      0     0    0
17676ee  fffffff6 work application stack           sm      0     0    0
1417986  fffffff8 work application stack           sm      0     0    0

We see that for this process, only 3,351 4KB pages are exclusive to the process.

3351 x 4 = 13404K or about 13MB

This number however, can change significantly while the process is running, especially for a 64-bit process.

[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Support information","Platform":[{"code":"PF002","label":"AIX"}],"Version":"5.3;6.1;7.1","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
17 June 2018

UID

isg3T1012834